package test.movies;

import katris.selenium.tests.util.BaseTest;

import org.testng.Assert;
import org.testng.annotations.Test;

public class DeleteDescription  extends BaseTest {


    // Logger variable
    private static final org.apache.log4j.Logger LOGGER = org.apache.log4j.Logger.getLogger(DeleteDescription.class);


    // Film Name
    private String filmName = "Neptyn";

  //  @Test(priority = 3)
    public void delete_Description() {


        LOGGER.info("//========================================================");
        LOGGER.info("Starting test :  deleting of film description ");
        LOGGER.info("//========================================================");

        LoginPage authorize = new LoginPage(app.getWebDriver(), app.getMovieUrl());

        // open Login Page
        authorize.openMoviesServer();

        // check if Login page is open
        boolean checkLoginPage = authorize.checkIfLoginPageIsOpen();
        Assert.assertTrue(checkLoginPage, "Login page is not open!!!!");

        // Login to application
        MainPage main = authorize.authorization("admin", "admin");
        Assert.assertNotNull(main,"Error while authorization: Can't find fields to authorize");

        // check if Main page is open
        boolean checkMainPage = main.checkIfMainPageIsOpen();
        Assert.assertTrue(checkMainPage,"User is not authorised !!!!");

        // delete Description
        boolean checkDeletion = main.removeDescription(filmName);
        Assert.assertTrue(checkDeletion,"Error during removing of new description !!!!");

        //do Log out
        LoginPage doLogOut = main.logOut();
        Assert.assertNotNull(doLogOut,"Button LogOut is not found!!!");

        // check if Login page is open
        boolean backLoginPage = doLogOut.checkIfLoginPageIsOpen();
        Assert.assertTrue(backLoginPage, "Back to Login page is not done!!!!");


    }

}

